/*
 * Copyright (C) 2022 KylinSoft Co., Ltd.
 *
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <https://www.gnu.org/licenses/>.
 */

import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.12
import QtQml 2.12
import org.ukui.tablet 1.0
import org.ukui.qqc2style.private 1.0 as StylePrivate
import "./baseComponent"
import "."

EduDesktopWindow {
    id: root
    width: Screen.width
    height: Screen.height
    visible: true

    MouseArea{
        anchors.fill: parent
        onClicked: {
            itemView.titleFocusChanged()
        }
    }

    EduTimeComponent {
        id: dateTime
        anchors.bottom: itemView.top
        anchors.bottomMargin: Style.widthScaleFactor * 20
        anchors.left: itemView.left
        anchors.leftMargin: Style.widthScaleFactor * 20
    }

    NetworkState{
        id: networkState
        anchors.top: parent.top
        anchors.topMargin: Style.widthScaleFactor * 8
        anchors.right: parent.right
        anchors.rightMargin: Style.widthScaleFactor * 10
    }

    EduLauncherView {
        id: itemView
        property real margin: Style.widthScaleFactor * (200-20)
        property real bottomMargin: Style.heightScaleFactor * (160-20)
        anchors {
            centerIn: parent
            topMargin: margin; leftMargin: margin;
            rightMargin: margin; bottomMargin: bottomMargin
        }
        width: Style.widthScaleFactor * (1520 + 40);
        height: Style.heightScaleFactor * (720 + 40)
        viewMoel: modelManager.launcherModel
        onShowAddAppWindow: {
            modelManager.setAddAppCategory(modelManager.containerCategory(groupId), groupId)
            addAppWindow.setClassifyId = modelManager.containerCategory(groupId)
            addAppWindow.groupId = groupId
            addAppWindow.groupPageIndex = pageIndex
            addAppWindow.showFullScreen()
        }
    }

    EduHoverButton {
        id: controlCenterButton
        anchors.bottom: parent.bottom
        anchors.bottomMargin: 48 * Style.widthScaleFactor
        anchors.left: parent.left
        anchors.leftMargin: 80 * Style.widthScaleFactor
        imageWidth: 40 * Style.widthScaleFactor
        imageHeight: 40 * Style.widthScaleFactor
        imagePath: "qrc:/ui/images/document-properties-symbolic.svg"
        execName: "ukui-control-center.desktop"
    }

    EduHoverButton {
        anchors.bottom: parent.bottom
        anchors.bottomMargin: 48 * Style.widthScaleFactor
        anchors.left: controlCenterButton.right
        anchors.leftMargin: 40 * Style.widthScaleFactor
        imageWidth:  44 * Style.widthScaleFactor
        imageHeight: 32 * Style.widthScaleFactor
        imagePath: "qrc:/ui/images/ukui_keyboard-symbolic.svg"
        execName: "onboard"
    }

    AddApp {
        id: addAppWindow
        visible: false
    }
}
